package com.google.bling.client;

import java.util.ArrayList;
import java.util.List;

import com.google.gwt.core.client.JavaScriptObject;
import com.google.gwt.json.client.JSONArray;

public class JSONHelper {
	public static List<String> toListString(JavaScriptObject o) {
		JSONArray json_array = new JSONArray(o);
		List<String> list = new ArrayList<String>();
		for (int i = 0, I = json_array.size(); i < I; ++i) {
			list.add(json_array.get(i).toString());
		}
		return list;
	}

	public static List<Double> toListDouble(JavaScriptObject o) {
		JSONArray json_array = new JSONArray(o);
		List<Double> list = new ArrayList<Double>();
		for (int i = 0, I = json_array.size(); i < I; ++i) {
			list.add(json_array.get(i).isNumber().doubleValue());
		}
		return list;
	}
}
